package com.yunhe.common.client.fallback;

import com.yunhe.common.client.WebAuthorityClient;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.*;
import com.yunhe.common.model.company.Company;
import com.yunhe.common.model.company.Employee;
import com.yunhe.common.model.office.Office;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

/**
 * @author liuronglei
 */
@Component
public class WebAuthorityFallbackFactory implements FallbackFactory<WebAuthorityClient> {
    @Override
    public WebAuthorityClient create(Throwable arg0) {
        return new WebAuthorityClient() {

            @Override
            public ResponseEntity<ResultObject<User>> getUserById(Long userId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Station>> getStationById(Long stationId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Firm>> getFirmById(Long firmId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Organization>> getOrgById(Long orgId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Office>> getOfficeById(Long officeId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<RealStation>> getRealStationById(Long fieldValueLong) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Company>> getCompanyById(Long fieldValueLong) throws ObjectNotFoundException {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Employee>> getEmployeeById(Long fieldValueLong) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
